import { Controller, Get, Post, Body, Patch, Param, Delete, Header, HttpCode } from '@nestjs/common';
import { OrderService } from './order.service';
import { CreateOrderDto } from './dto/create-order.dto';
import { UpdateOrderDto } from './dto/update-order.dto';

@Controller('order')
export class OrderController {
  constructor(private readonly orderService: OrderService) { }

  @Post('save')
  @HttpCode(200)
  create(@Body() createOrderDto: CreateOrderDto) {
    return this.orderService.create(createOrderDto);
  }

  //列表查询
  @Post('list')
  @Header('Content-Type', 'application/json')
  @HttpCode(200)
  findAll(
    @Body('pageNum') pageNum: number,
    @Body('pageSize') pageSize: number,
    @Body('bossName') bossName: string,
  ) {
    return this.orderService.findAll(pageNum, pageSize, bossName);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.orderService.findOne(+id);
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateOrderDto: UpdateOrderDto) {
    return this.orderService.update(+id, updateOrderDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.orderService.remove(+id);
  }
}
